<template>
  <div class="app">
    <h2>我是App</h2>
    <h4>儿子给的玩具：{{wanju}}</h4>
    <h4>儿子给的电脑：{{diannao}}</h4>
    <!-- 给Child的实例(vc)绑定事件 -->
    <Child 
      @send-toy="getToy" 
      @send-computer="getComputer"
    />
  </div>
</template>

<script>
  import Child from './components/Child.vue'
  export default {
    name:'App',
    components:{Child},
    data() {
      return {
        wanju:'',
        diannao:''
      }
    },
    methods: {
      getToy(value){
        console.log('你出发了Child实例的send-toy事件',value)
        this.wanju = value
      },
      getComputer(value){
        console.log('你出发了Child实例的send-computer事件',value)
        this.diannao = value
      }
    },
  }
</script>

<style>
  .app {
    background-color: #ddd;
    border-radius: 10px;
    box-shadow: 0 0 10px;
    padding: 20px;
  }
</style>